import java.util.ArrayList;
import java.util.Collections;

/*
 * Class Deck.
 * Collection of questions, supports all methods of ArrayList. Arguments are required when creating object.
 * Method addAndShuffle must be used if questions need to be randomised.
 * Returns total score and total number of possible correct answers.
 */
public class Deck extends ArrayList<Question> {
	
	private String name;
	
	private Deck() {}
	
	public Deck(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public boolean addAndShuffle(Question question){
		boolean ret = super.add(question);
		shuffle();
		return ret;
	}
	
	public int getScore() {
		int score = 0;
		for (int i = 0; i < this.size(); i++) {
			score += get(i).getScore();
		}
		return score;
	}
	
	public int getTotal() {
		int total = 0;
		for (int i = 0; i < this.size(); i++) {
			total+= get(i).getTotalCorrect();
		}
		return total;
	}
	
	public void shuffle(){
		Collections.shuffle(this);
	}
	
}
